console.log("Testing network connectivity...");
const http = require('http');

const options = {
    hostname: 'localhost',
    port: 8000,
    path: '/api/v1/index/category',
    method: 'GET'
};

const req = http.request(options, (res) => {
    console.log(`STATUS: ${res.statusCode}`);
    console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
    
    let data = '';
    res.on('data', (chunk) => {
        data += chunk;
    });
    
    res.on('end', () => {
        console.log('Response:', data);
        process.exit(0);
    });
});

req.on('error', (e) => {
    console.error(`Problem with request: ${e.message}`);
    process.exit(1);
});

req.setTimeout(5000, () => {
    console.log('Request timeout');
    req.destroy();
    process.exit(1);
});

req.end();
